package mock.action;

import java.util.Map;

import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;

import mock.bo.Authenticate;
import mock.bo.AuthenticateImp;
import mock.dao.CardDAO;
import mock.dao.CardDAOImp;

import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class AuthenticateAction extends ActionSupport implements SessionAware{
	
	private Authenticate au = new AuthenticateImp();
	private String txtPIN;
	private Map<String, Object> session;

	public String getTxtPIN() {
		return txtPIN;
	}

	public void setTxtPIN(String txtPIN) {
		this.txtPIN = txtPIN;
	}

	@Override
	public void setSession(Map<String, Object> session) {
		// TODO Auto-generated method stub
		this.session = session;
	}
	
	
	
	/**
	 * kiem tra ma PIN co hop le so voi ma PIN trong database hay khong
	 */
	@Override
	public String execute() throws Exception {
		String cardNo = (String)session.get("cardNo");
		return au.validatePIN(txtPIN, cardNo);
		//return "test";
	}

}
